import os
import sys
from django.conf import settings
from conf.env import *
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

ASGI_APPLICATION = 'websocket_plugin.asgi.application'

# redis_host = "redis://" + REDIS_HOST + ":" + REDIS_PORT + "/" + REDIS_LIBRARY
redis_host = "redis://:" + REDIS_PWD + "@" + REDIS_HOST + ":" + REDIS_PORT + "/" + REDIS_LIBRARY
secret_k = 'wchime'

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            # 连接自己的redis
            "hosts": [redis_host],
            "symmetric_encryption_keys": [secret_k],
        },
    },
}

apps = ['channels']

settings.INSTALLED_APPS += [app for app in apps if app not in settings.INSTALLED_APPS]
